package com.wang.dao;

import com.wang.domain.ExpertEntity;
import com.wang.domain.UserEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by Administrator on 2017/2/11 0011.
 */
public interface ExpertEntityDao extends JpaRepository<ExpertEntity,Integer> {
    /**
     * 匹配姓名得到专家
     * @param name
     * @return
     */
    ExpertEntity findByName(String name);

    /**
     * 随机抽取指定数量的专家信息
     * @param limit
     * @return
     */
    @Query(value = "SELECT * from expert where ?1<0 or type=?1 ORDER BY RAND() limit ?2",
            nativeQuery = true)
    List<ExpertEntity> selectRandoms(int type, int limit);
}